<html xmlns="http://www.w3.org/1999/xhtml">
<head th:include="commonBase">
<title>导入文件</title>
</head>
<link rel="stylesheet" th:href="@{/common/css/fileIcon.css}"/>
<link rel="stylesheet" th:href="@{/bootstrap/css/bootstrap.min.css}"/>
<script th:src="@{/bootstrap/js/bootstrap.min.js}" type="text/javascript"></script>
<link rel="stylesheet" th:href="@{/plugins/fileinput/css/fileinput.min.css}"/>
<link rel="stylesheet" th:href="@{/common/js/miniui/res/font-awesome/css/font-awesome.min.css}"/>
<link rel="stylesheet" th:href="@{/plugins/fileinput/themes/explorer-fa/theme.css}"/>
<script th:src="@{/plugins/fileinput/js/fileinput.min.js}" type="text/javascript"></script>
<script th:src="@{/plugins/fileinput/js/zh.js}" type="text/javascript"></script>
<script th:src="@{/plugins/fileinput/themes/fa/theme.js}" type="text/javascript"></script>
<script th:src="@{/plugins/fileinput/themes/explorer-fa/theme.js}" type="text/javascript"></script>
<body>
<div class="mini-fit">
	<div style="width:100%;height:350px;">
	<input id="fileId" name="excelFile" type="file" multiple="multiple" class="file-loading" ></input>
	</div>
</div>
</body>
<script type="text/javascript">
 /*<![CDATA[*/
      function setData(data) {
    		var action = data.action;//获取指令，是新增 还是修改
    		data = mini.clone(data);//获取克隆数据
    	}
 $("#fileId").fileinput({
				language : 'zh',
				uploadUrl : basePath + 'dict/importExcel',
				maxFileCount : 1,//表示允许同时上传的最大文件个数
				maxFileSize:204800,
				showCaption : true,//是否显示标题
				browseClass : "btn btn-primary", //按钮样式
				showPreview:true,
			    allowedFileExtensions: ["xls", "xlsx"],
				uploadAsync:true,
				enctype : 'multipart/form-data',//不对发送的字符进行编码
				previewFileIcon : "<i class='glyphicon glyphicon-king'></i>",
				msgFilesTooMany : "选择上传的文件数量({n}) 超过允许的最大数值{m}！",
				 previewFileIconSettings: {
				        'doc': '<i class="fa fa-file-word-o text-primary"></i>',
				        'xls': '<i class="fa fa-file-excel-o text-success"></i>',
				        'ppt': '<i class="fa fa-file-powerpoint-o text-danger"></i>',
				        'jpg': '<i class="fa fa-file-photo-o text-warning"></i>',
				        'pdf': '<i class="fa fa-file-pdf-o text-danger"></i>',
				        'zip': '<i class="fa fa-file-archive-o text-muted"></i>',
				        'htm': '<i class="fa fa-file-code-o text-info"></i>',
				        'txt': '<i class="fa fa-file-text-o text-info"></i>',
				        'mov': '<i class="fa fa-file-movie-o text-warning"></i>',
				        'mp3': '<i class="fa fa-file-audio-o text-warning"></i>',
				    },
				    previewFileExtSettings: {
				        'doc': function(ext) {
				            return ext.match(/(doc|docx)$/i);
				        },
				        'xls': function(ext) {
				            return ext.match(/(xls|xlsx)$/i);
				        },
				        'ppt': function(ext) {
				            return ext.match(/(ppt|pptx)$/i);
				        },
				        'zip': function(ext) {
				            return ext.match(/(zip|rar|tar|gzip|gz|7z)$/i);
				        },
				        'htm': function(ext) {
				            return ext.match(/(php|js|css|htm|html)$/i);
				        },
				        'txt': function(ext) {
				            return ext.match(/(txt|ini|md)$/i);
				        },
				        'mov': function(ext) {
				            return ext.match(/(avi|mpg|mkv|mov|mp4|3gp|webm|wmv)$/i);
				        },
				        'mp3': function(ext) {
				            return ext.match(/(mp3|wav)$/i);
				        },
				    }
			});
			$("#fileId").on('fileuploaded', function(event, data, previewId, index) {
				var message = mini.decode(data);
		    	if(message.type == '200'){
		        	showMsg("导入excel数据成功","success",2000,"center","center");
		    	    search();
		    	    var storage=window.localStorage;
	            	storage.removeItem("dictData");
	            	$.ajax({  
	    	            type: "get",  
	    	            dataType: "json",  
	    	            url: basePath+"dict/list",  
	    	            data:null,  
	    	            success: function (data) {  
	    	            	var dictData=JSON.stringify(data);
	    	                 storage.setItem("dictData",dictData);
	    	            } 
	    	        });  
		    	}else{
		    		showMsg("导入excel数据成功","warning",2000,"center","center");
		    	}
			});
            
 /*]]>*/
</script>
</html>
